package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.WorkerPosition;
import com.ruoyi.system.service.iWorkerPositionService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工-职位Controller
 *
 * @author ruoyi
 * @date 2024-05-13
 */
@RestController
@RequestMapping("/system/WorkerPosition")
public class workerPositionController extends BaseController
{
    @Autowired
    private iWorkerPositionService WorkerPositionService;

    /**
     * 查询员工-职位列表
     */
    @PreAuthorize("@ss.hasPermi('system:WorkerPosition:list')")
    @GetMapping("/list")
    public TableDataInfo list(WorkerPosition WorkerPosition)
    {
        startPage();

        List<WorkerPosition> list = WorkerPositionService.selectWorkerPositionList(WorkerPosition);
        return getDataTable(list);
    }

    /**
     * 导出员工-职位列表
     */
    @PreAuthorize("@ss.hasPermi('system:WorkerPosition:export')")
    @Log(title = "员工-职位", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WorkerPosition WorkerPosition)
    {
        List<WorkerPosition> list = WorkerPositionService.selectWorkerPositionList(WorkerPosition);
        ExcelUtil<WorkerPosition> util = new ExcelUtil<WorkerPosition>(WorkerPosition.class);
        util.exportExcel(response, list, "员工-职位数据");
    }

    /**
     * 获取员工-职位详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:WorkerPosition:query')")
    @GetMapping(value = "/{positionId}")
    public AjaxResult getInfo(@PathVariable("positionId") Long positionId)
    {
        return success(WorkerPositionService.selectWorkerPositionByPositionId(positionId));
    }

    /**
     * 新增员工-职位
     */
    @PreAuthorize("@ss.hasPermi('system:WorkerPosition:add')")
    @Log(title = "员工-职位", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WorkerPosition WorkerPosition)
    {
        return toAjax(WorkerPositionService.insertWorkerPosition(WorkerPosition));
    }

    /**
     * 修改员工-职位
     */
    @PreAuthorize("@ss.hasPermi('system:WorkerPosition:edit')")
    @Log(title = "员工-职位", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WorkerPosition WorkerPosition)
    {
        return toAjax(WorkerPositionService.updateWorkerPosition(WorkerPosition));
    }

    /**
     * 删除员工-职位
     */
    @PreAuthorize("@ss.hasPermi('system:WorkerPosition:remove')")
    @Log(title = "员工-职位", businessType = BusinessType.DELETE)
	@DeleteMapping("/{positionIds}")
    public AjaxResult remove(@PathVariable Long[] positionIds)
    {
        return toAjax(WorkerPositionService.deleteWorkerPositionByPositionIds(positionIds));
    }
}
